package com.quwan.common.service.impl;

import com.quwan.common.form.PushForm;
import com.quwan.common.result.PushDTO;
import com.quwan.common.service.PushService;
import com.quwan.common.service.impl.ums.AndroidUMSMessage;
import com.quwan.common.service.impl.ums.IosUMSMessage;
import com.quwan.common.service.impl.ums.UMSPush;
import com.quwan.common.service.push.AbstractMessage;
import com.quwan.common.service.push.MsgSender;
import com.quwan.config.yml.PushConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class PushServiceImpl implements PushService {
    @Autowired
    private PushConfig pushConfig;


    @Override
    public PushDTO pushAndroidAll(PushForm pushForm) {
        MsgSender msgSender = new AndroidUMSMessage();
        AbstractMessage message = new UMSPush(msgSender);
        PushDTO pushDTO = message.sendAllMessage(pushForm,pushConfig);
        return pushDTO;
    }

    @Override
    public PushDTO pushAndroid(PushForm pushForm) {
        // 推送到安卓
        MsgSender msgSender = new AndroidUMSMessage();
        AbstractMessage message = new UMSPush(msgSender);
        PushDTO pushDTO = message.sendTokenMessage(pushForm,pushConfig);
        return pushDTO;
    }

    @Override
    public PushDTO pushIosAll(PushForm pushForm) {
        MsgSender msgSender = new IosUMSMessage();
        AbstractMessage message = new UMSPush(msgSender);
        PushDTO pushDTO = message.sendAllMessage(pushForm,pushConfig);
        return pushDTO;
    }

    @Override
    public PushDTO pushIos(PushForm pushForm) {
        MsgSender msgSender = new IosUMSMessage();
        AbstractMessage message = new UMSPush(msgSender);
        PushDTO pushDTO = message.sendTokenMessage(pushForm,pushConfig);
        return pushDTO;
    }

}
